﻿namespace Devonline.Entity;

/// <summary>
/// 基础数据, 字符串类型的默认实现
/// </summary>
[Cacheable(LocalCache = true)]
[Table("parameter"), DisplayName("基础数据")]
public class Parameter : Parameter<string>, IKeyValuePair, IParent, IEntitySet, IEntitySetWithCreate
{
    /// <summary>
    /// 父项基础数据
    /// </summary>
    public virtual Parameter? Parent { get; set; }
    /// <summary>
    /// 子项基础数据
    /// </summary>
    public virtual ICollection<Parameter>? Children { get; set; }
}

/// <summary>
/// 基础数据
/// </summary>
[Table("parameter"), DisplayName("基础数据")]
public abstract class Parameter<TKey> : EntitySetWithKeyValuePair<TKey>, IKeyValuePair<TKey>, IParent<TKey>, IEntitySet<TKey>, IEntitySetWithCreate<TKey> where TKey : IConvertible
{
    /// <summary>
    /// 基础数据项显示的文本
    /// </summary>
    [Column("text"), DisplayName("文本"), Required, MaxLength(128), Excel]
    public virtual string? Text { get; set; }
    /// <summary>
    /// 父项编号
    /// </summary>
    [Column("parent_id"), DisplayName("父级编号"), MaxLength(36), Excel]
    public virtual TKey? ParentId { get; set; }
}